package edu.westga.sketchit2009cs.stringBufferServer;

import edu.westga.sketchit2009cs.gui.*;

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.net.Socket;

public class DrawingClient {
	
	private Socket socket;
	private PrintWriter out;
	private BufferedReader in;
	
	public DrawingClient() {
		//Create socket connection
		try {
			socket = new Socket(Sketchit2009csMainFrame.hostIpAddress, 4999);
			out = new PrintWriter(socket.getOutputStream(), true);
			in = new BufferedReader(new InputStreamReader(socket.getInputStream()));
		} catch (Exception e) {
			//System.out.println("Unknown host: at " + Sketchit2009csMainFrame.hostIpAddress);
		} 
	}
	
	public void send(String data) {
		try {
			out.println(data);	
		}
		catch(Exception e) {
			//System.out.println("data lost because of a " + e.toString());
		}
	}
	
	public String recieve() {
		try {
			String theLine = in.readLine();
			//System.out.println(theLine);
			return theLine;
		} catch (Exception e) {
			return "";
		}
	}

}
